﻿// -------------------------------------------------------------------------------------------------------------------------------
// <copyright file="CMDenseMatrixCMDenseMatrixRingOperationsProvider.cs" company="Exul">
//     Copyright (c) Exul. All rights reserved.
// </copyright>
// <author>
//     Exul
// </author>
// -------------------------------------------------------------------------------------------------------------------------------

namespace ExulLibrary.Mathematics.LinearAlgebra.Sequential.DecimalExtensions
{
    #region Usings

    using System;

    #endregion

    /// <summary>
    ///     Provides operations for <see cref="CMDenseMatrix{T}"/> through interface.
    /// </summary>
    internal sealed class CMDenseMatrixCMDenseMatrixRingOperationsProvider
        : IMatrixMatrixRingOperationsProvider<decimal>
    {
        #region Implemented Interfaces

        #region IMatrixMatrixRingOperationsProvider<decimal>

        /// <summary>
        ///     Adds the second matrix to the first matrix.
        /// </summary>
        /// <param name="augend">
        ///     The augend matrix.
        /// </param>
        /// <param name="addend">
        ///     The addend matrix.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="augend"/> is <see langword="null"/>.
        ///     <para>
        ///         --or--
        ///     </para>
        ///     <para>
        ///         <paramref name="addend"/> is <see langword="null"/>.
        ///     </para>
        /// </exception>
        public void Add(Matrix<decimal> augend, Matrix<decimal> addend)
        {
            var realAugend = augend as CMDenseMatrix<decimal>;
            var realAddend = addend as CMDenseMatrix<decimal>;
            realAugend.Add(realAddend);
        }

        /// <summary>
        ///     Adds the second matrix to the first matrix multiplied by the factor.
        /// </summary>
        /// <param name="augend">
        ///     The augend matrix.
        /// </param>
        /// <param name="augendFactor">
        ///     The factor of the augend matrix.
        /// </param>
        /// <param name="addend">
        ///     The addend matrix.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="augend"/> is <see langword="null"/>.
        ///     <para>
        ///         --or--
        ///     </para>
        ///     <para>
        ///         <paramref name="addend"/> is <see langword="null"/>.
        ///     </para>
        /// </exception>
        public void Add(Matrix<decimal> augend, decimal augendFactor, Matrix<decimal> addend)
        {
            var realAugend = augend as CMDenseMatrix<decimal>;
            var realAddend = addend as CMDenseMatrix<decimal>;
            realAugend.Add(augendFactor, realAddend);
        }

        /// <summary>
        ///     Adds the second matrix multiplied by the factor to the first matrix.
        /// </summary>
        /// <param name="augend">
        ///     The augend matrix.
        /// </param>
        /// <param name="addend">
        ///     The addend matrix.
        /// </param>
        /// <param name="addendFactor">
        ///     The factor of the addend matrix.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="augend"/> is <see langword="null"/>.
        ///     <para>
        ///         --or--
        ///     </para>
        ///     <para>
        ///         <paramref name="addend"/> is <see langword="null"/>.
        ///     </para>
        /// </exception>
        public void Add(Matrix<decimal> augend, Matrix<decimal> addend, decimal addendFactor)
        {
            var realAugend = augend as CMDenseMatrix<decimal>;
            var realAddend = addend as CMDenseMatrix<decimal>;
            realAugend.Add(realAddend, addendFactor);
        }

        /// <summary>
        ///     Adds the second matrix multiplied by the second factor to the first matrix multiplied by the first factor.
        /// </summary>
        /// <param name="augend">
        ///     The augend matrix.
        /// </param>
        /// <param name="augendFactor">
        ///     The factor of the augend matrix.
        /// </param>
        /// <param name="addend">
        ///     The addend matrix.
        /// </param>
        /// <param name="addendFactor">
        ///     The factor of the addend matrix.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="augend"/> is <see langword="null"/>.
        ///     <para>
        ///         --or--
        ///     </para>
        ///     <para>
        ///         <paramref name="addend"/> is <see langword="null"/>.
        ///     </para>
        /// </exception>
        public void Add(Matrix<decimal> augend, decimal augendFactor, Matrix<decimal> addend, decimal addendFactor)
        {
            var realAugend = augend as CMDenseMatrix<decimal>;
            var realAddend = addend as CMDenseMatrix<decimal>;
            realAugend.Add(augendFactor, realAddend, addendFactor);
        }

        /// <summary>
        ///     Subtracts the second matrix from the first matrix.
        /// </summary>
        /// <param name="minuend">
        ///     The minuend matrix.
        /// </param>
        /// <param name="subtrahend">
        ///     The subtrahend matrix.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="minuend"/> is <see langword="null"/>.
        ///     <para>
        ///         --or--
        ///     </para>
        ///     <para>
        ///         <paramref name="subtrahend"/> is <see langword="null"/>.
        ///     </para>
        /// </exception>
        public void Subtract(Matrix<decimal> minuend, Matrix<decimal> subtrahend)
        {
            var realMinuend = minuend as CMDenseMatrix<decimal>;
            var realSubtrahend = subtrahend as CMDenseMatrix<decimal>;
            realMinuend.Subtract(realSubtrahend);
        }

        /// <summary>
        ///     Subtracts the second matrix from the first matrix multiplied by the factor.
        /// </summary>
        /// <param name="minuend">
        ///     The minuend matrix.
        /// </param>
        /// <param name="minuendFactor">
        ///     The factor of the minuend matrix.
        /// </param>
        /// <param name="subtrahend">
        ///     The subtrahend matrix.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="minuend"/> is <see langword="null"/>.
        ///     <para>
        ///         --or--
        ///     </para>
        ///     <para>
        ///         <paramref name="subtrahend"/> is <see langword="null"/>.
        ///     </para>
        /// </exception>
        public void Subtract(Matrix<decimal> minuend, decimal minuendFactor, Matrix<decimal> subtrahend)
        {
            var realMinuend = minuend as CMDenseMatrix<decimal>;
            var realSubtrahend = subtrahend as CMDenseMatrix<decimal>;
            realMinuend.Subtract(minuendFactor, realSubtrahend);
        }

        /// <summary>
        ///     Subtracts the second matrix multiplied by the factor from the first matrix.
        /// </summary>
        /// <param name="minuend">
        ///     The minuend matrix.
        /// </param>
        /// <param name="subtrahend">
        ///     The subtrahend matrix.
        /// </param>
        /// <param name="subtrahendFactor">
        ///     The factor of the subtrahend matrix.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="minuend"/> is <see langword="null"/>.
        ///     <para>
        ///         --or--
        ///     </para>
        ///     <para>
        ///         <paramref name="subtrahend"/> is <see langword="null"/>.
        ///     </para>
        /// </exception>
        public void Subtract(Matrix<decimal> minuend, Matrix<decimal> subtrahend, decimal subtrahendFactor)
        {
            var realMinuend = minuend as CMDenseMatrix<decimal>;
            var realSubtrahend = subtrahend as CMDenseMatrix<decimal>;
            realMinuend.Subtract(realSubtrahend, subtrahendFactor);
        }

        /// <summary>
        ///     Subtracts the second matrix multiplied by the second factor from the first matrix multiplied by the first factor.
        /// </summary>
        /// <param name="minuend">
        ///     The minuend matrix.
        /// </param>
        /// <param name="minuendFactor">
        ///     The factor of the minuend matrix.
        /// </param>
        /// <param name="subtrahend">
        ///     The subtrahend matrix.
        /// </param>
        /// <param name="subtrahendFactor">
        ///     The factor of the subtrahend matrix.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="minuend"/> is <see langword="null"/>.
        ///     <para>
        ///         --or--
        ///     </para>
        ///     <para>
        ///         <paramref name="subtrahend"/> is <see langword="null"/>.
        ///     </para>
        /// </exception>
        public void Subtract(Matrix<decimal> minuend, decimal minuendFactor, Matrix<decimal> subtrahend, decimal subtrahendFactor)
        {
            var realMinuend = minuend as CMDenseMatrix<decimal>;
            var realSubtrahend = subtrahend as CMDenseMatrix<decimal>;
            realMinuend.Subtract(minuendFactor, realSubtrahend, subtrahendFactor);
        }

        #endregion

        #endregion
    }
}